package com.leo.algorithm.排序;

/**
 * 选择排序
 */
public class SelectionSort {


    public static void main(String[] args) {
        int arr[]={2,4,1,6,5,8,9,10,3,7};
        int[] bub = selecttion(arr);
        for (int i = 0; i <bub.length ; i++) {
            System.out.println(bub[i]);
        }
    }
    
    private static int [] selecttion(int [] arr){
        
        for (int i=0;i<arr.length;i++){

            for (int j = i; j <arr.length ; j++) {
                int index=i;
                if(arr[j]<arr[index]){
                    index=j;
                }
                int temp=arr[index];
                arr[index]=arr[i];
                arr[i]=temp;
            }
            
        }
        
        return arr;
    }









}
